﻿using System;
using System.Text;
using Token.Piker.Common;
using Token.Piker.Core;

namespace Token.Piker.Web
{
    public partial class album_list : System.Web.UI.Page
    {
        public string RightNav = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OutputRightNav();
            }
        }

        protected string GetScript()
        {
            string userName = null;
            bool isLogin = false;

            if (Session[GlobalConstants.PIKER_USER_NAME] != null)
            {
                userName = Session[GlobalConstants.PIKER_USER_NAME].ToString();
                isLogin = true;
            }

            if (userName != null)
            {
                return "Page={IsLogin:'" + isLogin.ToString().ToUpper() + "', UserName:'" + userName + "',HostUrl:'" + Server.HtmlEncode(Request.Url.AbsoluteUri) + "'};";
            }
            else
            {
                return "Page={IsLogin:'" + isLogin.ToString().ToUpper() + "',HostUrl:'" + Server.HtmlEncode(Request.Url.AbsoluteUri) + "'}; ";
            }
        }

        private void OutputRightNav()
        {
            //List<NewsAlbum> list = albumBLL.GetModelList("1=1");
            DateTime now = DateTime.Now;
            DateTime dt1 = now.AddMonths(-1);
            DateTime dt2 = now.AddMonths(-2);
            DateTime dt3 = now.AddMonths(-3);
            DateTime dt4 = now.AddMonths(-4);
            DateTime dt5 = now.AddMonths(-5);

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        now.ToString("yyyy-MM"), now.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        dt1.ToString("yyyy-MM"), dt1.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        dt2.ToString("yyyy-MM"), dt2.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        dt3.ToString("yyyy-MM"), dt3.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        dt4.ToString("yyyy-MM"), dt4.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}\" target=\"content_frame\">{1}</a></li>",
                        dt5.ToString("yyyy-MM"), dt5.ToString("yyyy年M月档"));
            sb.AppendFormat("<li><a href=\"album_list_iframe.aspx?date={0}&pre=1\" target=\"content_frame\">更早</a></li>",
                        dt5.ToString("yyyy-MM"), dt5.ToString("yyyy年M月档"));

            RightNav = sb.ToString();
        }

    }
}